package com.hjq.demo.ui.adapter

import android.content.Context
import android.view.ViewGroup
import com.google.android.material.textview.MaterialTextView
import com.hjq.demo.R
import com.hjq.demo.app.AppAdapter
import com.hjq.demo.http.model.AppM

/**  套餐列表  适配器
 *    author : Android 轮子哥
 *    github : https://github.com/getActivity/AndroidProject-Kotlin
 *    time   : 2018/11/05
 *    desc   :
 */
class MealAdapter constructor(context: Context) : AppAdapter<AppM.DataDTO.SetMealDTO>(context) {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder()
    }

    inner class ViewHolder : AppViewHolder(R.layout.meal_item) {
        private val tv_timelong: MaterialTextView? by lazy { findViewById(R.id.tv_timelong) }
        private val tv_unit_price: MaterialTextView? by lazy { findViewById(R.id.tv_unit_price) }
        override fun onBindView(position: Int) {
            val item = getItem(position);
            tv_timelong?.setText(item?.name)
            tv_unit_price?.setText("￥${item?.price}")
        }
    }
}